#include<bits/stdc++.h>

using namespace std;

const int N = 1e6 + 10;

int n;
int k;
int q[N];

int kth_elem(int a[], int low, int high, int k){
	int pivot = a[low];
	int low_temp = low;
	int high_temp = high;
	
	while(low < high){
		while(low < high && a[high] >= pivot){
			high--;
		}
		a[low] = a[high];
		while(low < high && a[low] <= pivot){
			low++;
		}
		a[high] = a[low];
	}
	
	a[low] = pivot;
	if(low == k){
		return a[low];
	}else if(low > k){
		return kth_elem(a, low_temp, low-1, k);
	}else{
		return kth_elem(a, low+1, high_temp, k);
	}
}

int main(){
	
	scanf("%d", &n);
	scanf("%d", &k);
	for(int i=0;i<n;i++){
		scanf("%d", &q[i]);
	}
	
	
	printf("%d\n", kth_elem(q,0,n-1,k-1));
	
//	for(int i=0; i<n; i++){
//		printf("%d", q[i]);
//	}
	
	return 0;
} 
